import { useMenuStore } from '@/stores/index'

import { useUserStore } from '@/stores/index'

export default function () {
  let { token, tokenExpired = 0 } = localStorage
  let now = +new Date()
  if (!token || now >= tokenExpired) {
    //  如果没有token或者token过期了 直接去初始化
    return Promise.resolve()
  }

  //  调用 获取菜单的方法
  let menuStore = useMenuStore() //
  let userStore = useUserStore()

  return Promise.all([menuStore.getMenu(), userStore.getUserInfo()])
}
